package com.example.park

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.lib_base.mvvm.BaseActivity
import com.example.park.databinding.ActivityParkBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch

@Route(path = "/park/ParkActivity")
@AndroidEntryPoint
class ParkActivity : BaseActivity<ActivityParkBinding,ParkViewModel>() {
   val parkAdapter by lazy { ParkAdapter() }
    override fun intiView() {
        binding.rvCarType.apply {
            adapter = parkAdapter
            layoutManager = LinearLayoutManager(this@ParkActivity)
        }
    }

    override fun intiData() {
        lifecycleScope.launch {
            vm.getCarType().collect() {
                parkAdapter.submitData(it)
            }
        }

    }
}